<template>
  <view>
    <div class="body"></div>
  </view>
</template>
<script setup>
import { getPayStat } from "@/api/apiList";
import { onLoad } from "@dcloudio/uni-app";
const getOpenChangeStatus = (ids) =>
  new Promise((resolve, reject) => {
    getPayStat(ids.id).then((res) => {
      if (res.code == 200) {
        return resolve(res);
      }
    });
  });

onLoad(async (id) => {

  getOpenChangeStatus(id).then(async (res) => {
    if(res.code == 200){
      if(res.data && res.data.length > 0){
        let flag = 0;
        for (let i = 0; i < res.data.length; i++) {
          if(res.data[i].circleId == id && res.data[i].payStats==1) {
            flag = 1;
            break;
          }
        }
        if(flag == 0){
          // uni.showToast({
          //   title: "支付失败",
          //   icon: "none",
          // });
          document.querySelector("body").innerHTML = uni.getStorageSync("resFrom");
          //调用submit 方法
          document.forms[0].submit();
        }else{
          uni.showModal({
            title: "支付成功",
            content: "支付成功",
            showCancel: false,
            success: function (res) {
              if (res.confirm) {
                uni.navigateBack({
                  delta: 1,
                });
              } else {
                uni.navigateBack({
                  delta: 1,
                });
              }
            },
          });
        }

      }
    }
  });
});
</script>
<style></style>
